package impl;

import mapper.Rolemapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import pojo.Role;
import service.RoleService;

/**
 * Created by zuoxiao
 * on 2019/7/6.
 */
@Service
public class RoleServiceImpl implements RoleService {
    @Autowired
    Rolemapper rolemapper = null;

    @Override
    @Transactional(propagation = Propagation.REQUIRES_NEW, isolation = Isolation.READ_COMMITTED)
    public int insertRole(Role role) {
        return rolemapper.insertRole(role);
    }

    @Transactional(propagation = Propagation.REQUIRES_NEW,timeout = 1,readOnly = true,isolation = Isolation.READ_COMMITTED)
    @Override
    public int deleteRole(Long id) {
        Role role = rolemapper.getRole(id);
        return rolemapper.deleteRole(role.getId());
    }
}
